%%--------------------------------------------------------------------
%% Record describing a beta memory callbacks.
%%--------------------------------------------------------------------
-record(mh,{module,handle}).

%%--------------------------------------------------------------------
%% Record describing a beta node server startup configuration.
%%--------------------------------------------------------------------
-record(beta_node_conf,
		{
		 id, 			% an atom identifying beta_node server
		 in_ids, 		% a list of atoms
		 out_pipe, 		% an output pipe
		 beta_mem_fun,	% beta memory factory fun -> #mh
		 red_fun,		% reduce function
		 red_mode = inc	% reduce mode (inc|aggr)
		}).
-define(IS_BETA_NODE_CONF(Conf),
		is_record(Conf,beta_node_conf)).
%%--------------------------------------------------------------------
%% Macro to validate (e.g. in guard condition) #beta_node_conf record.
%%--------------------------------------------------------------------
-define(IS_BETA_NODE_CONF_VALID(Conf),
	?IS_BETA_NODE_CONF(Conf),
	is_atom(Conf#beta_node_conf.id) andalso
 	is_list(Conf#beta_node_conf.in_ids) andalso
  	?IS_PIPE(Conf#beta_node_conf.out_pipe) andalso
  	is_function(Conf#beta_node_conf.beta_mem_fun,1) andalso
  	is_function(Conf#beta_node_conf.red_fun,3) andalso
  	(Conf#beta_node_conf.red_mode==inc orelse 
							 Conf#beta_node_conf.red_mode==aggr)).
%%--------------------------------------------------------------------
%% Record describing a beta memory modification request.
%%--------------------------------------------------------------------
-record(mdf_req,
		{
		 mdf_code,	% ins|del atom (i.e. insert or delete respectively)
		 input_id,	% input id (e.g. mapper id)
		 data		% {K,V} | [{K,V}]
		 }).

-define(IS_MDF_CODE(MdfCode),(MdfCode==ins orelse MdfCode==del)).